package com.lkd.handler;

import com.lkd.business.MsgHandler;
import com.lkd.config.TopicConfig;
import com.lkd.contract.SupplyContract;
import com.lkd.emq.Topic;
import com.lkd.service.ChannelService;
import com.lkd.utils.JsonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.io.IOException;

/**
 * @author brianxia
 * @version 1.0
 * @date 2022-07-20 9:19
 */
@Component
@Topic(TopicConfig.VMS_SUPPLY_TOPIC) //处理补货工单完成
public class SupplyCompleteHandler implements MsgHandler {

    @Autowired
    private ChannelService channelService;


    @Override
    public void process(String jsonMsg) throws IOException {
        //1.将json字符串转换成对象
        SupplyContract supplyContract = JsonUtil.getByJson(jsonMsg, SupplyContract.class);
        //2.处理补货逻辑
        channelService.supply(supplyContract);
    }

}
